package org.x.yuenovel.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author xuezhendong
 * @date 2022/4/23 3:48 下午
 */
@Getter
@AllArgsConstructor
public enum RoleEnum {
    /**
     * user
     */
    USER(1, "ROLE_USER"),
    ADMIN(2, "ROLE_ADMIN"),
    ;

    private final int role;

    private final String authority;

    public static String getAuthority(Integer role) {
        for (RoleEnum roleEnum : RoleEnum.values()) {
            if (roleEnum.role == role) {
                return roleEnum.authority;
            }
        }
        return null;
    }
}
